import request from "@/utils/request";
import { encryptedData } from "@/utils/encrypt";
import { loginRSA, tokenName } from "@/config/settings";

export async function login(data) {
  // if (loginRSA) {
  //   data = await encryptedData(data);
  // }
  return request({
    url: "/resourcevisualization/login",
    method: "post",
    data,
  });
}

export function getUserInfo(accessToken) {
  return request({
    url: "/resourcevisualization/user/getUserInfo",
    method: "get",
    data: {
      [tokenName]: accessToken,
    },
  });
}

export function getUserInfoByUsername(data) {
  return request({
    url: "/resourcevisualization/user/getUserInfoByUsername/" + data,
    method: "get",
  });
}

export function getUserList() {
  return request({
    url: "/resourcevisualization/user/getUserList",
    method: "get",
  });
}

export function getUserListByGroupName(userGroupName) {
  return request({
    url: "/resourcevisualization/user/getUserListByGroupName/" + userGroupName,
    method: "get",
  });
}

export function logout() {
  return request({
    url: "/resourcevisualization/logout",
    method: "post",
  });
}

export function register() {
  return request({
    url: "/resourcevisualization/user/register",
    method: "post",
  });
}
